//
//  HomeTongueCoatingView.m
//  Ginix
//
//  Created by 冯志强 on 2025/2/23.
//

#import "HomeTongueCoatingView.h"
#import "HomeTongueComView.h"
#import "HomeTongueTypeView.h"

@interface HomeTongueCoatingView()

@property (nonatomic,strong) HomeTongueComView * nameView;
@property (nonatomic,strong) UIImageView * iconView;

@property (nonatomic,strong) HomeTongueTypeView * wView;
@property (nonatomic,strong) HomeTongueTypeView * dhView;
@property (nonatomic,strong) HomeTongueTypeView * hView;
@end

@implementation HomeTongueCoatingView

-(instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        [self setSubViewLayout];
    }
    return self;
}

-(void)setSubViewLayout{
    
    [self addSubview:self.nameView];
    [_nameView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(@0);
        make.height.mas_offset(21 * FMScaleX);
    }];
    [self addSubview:self.wView];
    [_wView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_offset(CGSizeMake(98 * FMScaleX, 40 * FMScaleX));
        make.left.mas_offset(40 * FMScaleX);
        make.top.equalTo(self.nameView.mas_bottom).offset(32 * FMScaleX);
    }];
    [self addSubview:self.dhView];
    [_dhView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.top.equalTo(self.wView);
        make.left.equalTo(self.wView.mas_right).offset(1 * FMScaleX);
    }];
    [self addSubview:self.hView];
    [_hView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.top.equalTo(self.wView);
        make.left.equalTo(self.dhView.mas_right).offset(1 * FMScaleX);
    }];
    
    [self addSubview:self.iconView];
    [_iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_offset(CGSizeMake(16 * FMScaleX, 10 * FMScaleX));
        make.left.equalTo(self.wView.mas_left).offset(20 * FMScaleX);
        make.bottom.equalTo(self.dhView.mas_top).offset(-5 * FMScaleX);
    }];
}

-(void)setInfoModel:(HomeAllCheckInfoModel *)infoModel{
    
    if (infoModel) {
        CGFloat padding = (204 * FMScaleX) / 100;
        [self.iconView mas_updateConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.wView.mas_left).offset(padding * infoModel.tongueColor);
        }];
    }
}



-(HomeTongueComView *)nameView{
    
    if (!_nameView) {
        _nameView = [[HomeTongueComView alloc]init];
        _nameView.nameLabel.text = @"苔色:";

    }
    return _nameView;
}

-(UIImageView *)iconView{
    
    if (!_iconView) {
        _iconView = [[UIImageView alloc]init];
        _iconView.image = [UIImage imageNamed:@"Home_com_arrow_icon"];
    }
    return _iconView;
}
-(HomeTongueTypeView *)wView{
    
    if (!_wView) {
        _wView = [[HomeTongueTypeView alloc]init];
        [_wView setIndex:0];
    }
    return _wView;
}
-(HomeTongueTypeView *)dhView{
    
    if (!_dhView) {
        _dhView = [[HomeTongueTypeView alloc]init];
        [_dhView setIndex:1];
    }
    return _dhView;
}
-(HomeTongueTypeView *)hView{
    
    if (!_hView) {
        _hView = [[HomeTongueTypeView alloc]init];
        [_hView setIndex:2];
    }
    return _hView;
}
@end
